# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
import pymysql
class GirlPipeline(object):
    def __init__(self):
        self.conn = pymysql.Connect(host = '127.0.0.1',port = 3306,db = 'jinri',user = 'root',passwd = '000000',charset = 'utf8',)
        self.cursor = self.conn.cursor()
    def process_item(self, item, spider):
        sql = 'INSERT INTO xiaohua (url,name) VALUES ("%s","%s")' % (item['url'], item['name'])
        self.cursor.execute(sql)
        self.conn.commit()
        return item
    def close_spider(self,spider):
        self.cursor.close()
        self.conn.close()